const BASE_URL = "https://route.showapi.com";
const APP_KEY = "8256ec5a0e834cd4A73497b814A13901";

/**
 * GET
 * @param {String} URL
 * @param {Object} DATA
 */

export function getData(URL, DATA) {
	return new Promise((resolve, reject) => {
		uni.request({
			url: BASE_URL + URL + "?appKey=" + APP_KEY,
			data: DATA,
			method: "GET",
			success: res => {
				resolve(res.data);
			},
			fail: error => {
				reject(error);
			}
		});
	});
}

/**
 * POST
 * @param {String} URL
 * @param {Object} DATA
 */

export function postData(URL, DATA) {
	return new Promise((resolve, reject) => {
		uni.request({
			url: BASE_URL + URL + "?appKey=" + APP_KEY,
			data: DATA,
			method: "POST",
			header: {
				"Content-type": "application/json"
			},
			success: res => {
				resolve(res.data);
			},
			fail: error => {
				reject(error);
			}
		});
	});
}